[SUBROUTINE]
version = 1.14
icon = square.png
name = _("Workpiece")
type = workpiece2
help = _("<b>Workpiece or Raw material used</b>")
order = sh h1 l w d h2 x alx y aly z alz h4 cr wt cl

[PARAM_SH]
name = _("Show workpiece")
type = bool
value = 1
icon = glasses.png

[PARAM_H1]
type = sub-header
name = _("Size")

[PARAM_H2]
type = sub-header
name = _("Coords")

[PARAM_X]
name = _("X")
type = float
icon = x.png
tool_tip = _("X0")
value = 0.0
header = h2
metric_value = 0.0

[PARAM_Y]
name = _("Y")
type = float
icon = y.png
tool_tip = _("Y0")
value = 0.0
metric_value = 0.0
header = h2

[PARAM_Z]
name = _("Z")
type = float
icon = z.png
tool_tip = _("Surface")
value = 0.0
metric_value = 0.0
header = h2
hidden = 1

[PARAM_ALX]
name = _("X axis align")
icon = align-x.png
type = combo
options = _("Left=0:Center=1:Right=2")
value = 0
tool_tip = _("Define X reference")
header = h2

[PARAM_ALY]
name = _("Y axis align")
icon = align-y.png
type = combo
options = _("Top=0:Center=1:Bottom=2")
value = 2
tool_tip = _("Define Y reference")
header = h2

[PARAM_ALZ]
name = _("Z axis align")
type = combo
options = _("Top=0:Bottom=1")
value = 0
tool_tip = _("Define Z reference")
header = h2
hidden = 1

[PARAM_W]
name = _("Height (Y)")
type = float
icon = height.png
tool_tip = _("Y axis")
value = 20
header = h1
metric_value = 500
minimum_value = 0.0
not_allowed = 0

[PARAM_L]
name = _("Width (X)")
type = float
icon = width.png
tool_tip = _("X axis")
value = 40
header = h1
metric_value = 1000
minimum_value = 0.0
not_allowed = 0

[PARAM_D]
name = _("Depth (Z)")
type = float
icon = depth.png
tool_tip = _("Z axis")
value = 0.25
metric_value = 6.0
header = h1
minimum_value = 0.0
not_allowed = 0
hidden = 1

[PARAM_CL]
name = _("Centerline align")
type = combo
options = _("X axis=0:Y axis=1:Z axis=2")
value = 2
tool_tip = _("Define orientation of centerline")
header = h4
hidden = 1

[PARAM_H4]
name = _("Options")
type = sub-header

[PARAM_CR]
name = _("Corner radius")
type = float
value = 0.0
metric_value = 0.0
minimum_value = 0.0
tool_tip = _("Define radius")
header = h4
icon = corner-radius.png

[PARAM_WT]
name = _("Wall thickness")
type = float
value = 0.0
icon = wall-thickness.png
metric_value = 0.0
minimum_value = 0.0
tool_tip = _("Define if hollow")
header = h4
hidden = 1

[DEFINITIONS]
content =
;	<eval>self.include_once(file name here)</eval>

[CALL]
content =
	(begin #sub_name)
	(workpiece definition author : Fernand Veilleux)
	#<wp_width>         = [#param_w]
	#<wp_length>        = [#param_l]
	#<wp_depth>         = [#param_d]
	#<wp_wall>          = [#param_wt]
	#<wp_corner_radius> = [#param_cr]
	#<wp_inside_width>  = [#<wp_width> - #<wp_wall> * 2]
	#<wp_inside_length> = [#<wp_length> - #<wp_wall> * 2]
	
	#<wp_x> = #param_x
	#<wp_y> = #param_y
	
	o<select> CALL [31] [#param_alx] [#param_x] [#param_x - #<wp_length> / 2] [#param_x - #<wp_length>]
	#<wp_left>  = #31
	#<wp_right> = [#<wp_left> + #<wp_length>]
	
	o<select> CALL [31] [#param_aly] [#param_y - #<wp_width>] [#param_y - #<wp_width> / 2] [#param_y]
	#<wp_front> = #31
	#<wp_rear>  = [#<wp_front> + #<wp_width>]
	
	o<select> CALL [31] [#param_alz] [#param_z] [#param_z + #<wp_depth>]
	#<surface>  = #31
	
	#<bottom>   = [#<surface> - #<wp_depth>]
	
	/	o<#self_id_active> if [#param_sh] (show active)
	/		o<stock> CALL [#<wp_left>] [#<wp_right>] [#<wp_front>] [#<wp_rear>] [#<surface>] [#<bottom>] [#param_cl] [#<wp_corner_radius>] [#<wp_wall>]
	/		G0 X#param_x Y#param_y
	/		o<#self_id_has_Z_axis> if [#<_has_z_axis>]
	/			G0 Z#<surface>
	/		o<#self_id_has_Z_axis> endif
	/	o<#self_id_active> endif
	(end #sub_name)
